package nccloud.api.uapbd.file;

import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.fileupload.RequestContext;
import org.restlet.representation.Representation;

public class RepresentationContext implements RequestContext {
    private volatile Representation multipartForm;

    public RepresentationContext(Representation multipartForm) {
        this.multipartForm = multipartForm;
    }

    public String getCharacterEncoding() {
        return this.multipartForm.getCharacterSet() != null ? this.multipartForm.getCharacterSet().getName() : null;
    }

    public int getContentLength() {
        return (int)this.multipartForm.getSize();
    }

    public String getContentType() {
        return this.multipartForm.getMediaType() != null ? this.multipartForm.getMediaType().toString() : null;
    }

    public InputStream getInputStream() throws IOException {
        return this.multipartForm.getStream();
    }
}
